<?php
namespace BP\DA;
// require_once("java/math/BigDecimal.php");
// require_once("java/util/ArrayList.php");
// require_once("java/util/Date.php");
// require_once("BP/Sys/SystemConfig.php");
use BP\Sys\SystemConfig;
class Paras //extends ArrayList 
{
	protected static $serialVersionUID;	// long
	public $SQL;	// String
	protected $debugInfo;	// String
	private function __init() { // default class members
		$this->SQL = NULL;
		$this->debugInfo = NULL;
	}
	public static function __staticinit() { // static class members
		self::$serialVersionUID = 1;
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public static function constructor__Object ($o) // [Object o]
	{
		$me = new self();
		$me->__init();
		$me->Add_String_Object("p", $o);
		return $me;
	}
	public function getDBStr () 
	{
		return SystemConfig::getAppCenterDBVarStr();
	}
	public static function constructor__String_Object ($p, $v) // [String p, Object v]
	{
		$me = new self();
		$me->__init();
		$me->Add_String_Object($p, $v);
		return $me;
	}
	public static function constructor__String_Object_String_Object ($p1, $o1, $p2, $o2) // [String p1, Object o1, String p2, Object o2]
	{
		$me = new self();
		$me->__init();
		$me->Add_String_Object($p1, $o1);
		$me->Add_String_Object($p2, $o2);
		return $me;
	}
	public function Add_Para ($para) // [Para para]
	{
		foreach ($this as $p) 		{
			if ($p->ParaName->equals($para->ParaName))
			{
				$p->val = $para->val;
				return ;
			}
		}
		$this->add($para);
	}
	public function Add_Object ($obj) // [Object obj]
	{
		$this->Add_String_Object("p", $obj);
	}
	public function Add_String_Object ($_name, $obj) // [String _name, Object obj]
	{
		if ($_name->equals("abc"))
		{
			return ;
		}
		if (($obj == NULL))
		{
			throw new \Exception((("@参数:" . $_name) . " 值无�?."));
		}
		foreach ($this as $p) 		{
			if ($p->ParaName->equals($_name))
			{
				$p->val = $obj;
				return ;
			}
		}
			/* match: String_Object_Class */
		$this->Add_String_Object_Class($_name, $obj, $obj->getClass());
	}
	public function Add_String_Object_Class ($_name, $obj, $clazzType) // [String _name, Object obj, Class<?\> clazzType]
	{
		if ($_name->equals("abc"))
		{
			return ;
		}
		foreach ($this as $p) 		{
			if ($p->ParaName->equals($_name))
			{
				$p->val = $obj;
				return ;
			}
		}
		if (($clazzType . String))
		{
			$this->Add_String_String($_name, $obj);
			return ;
		}
		if (((($clazzType == Integer) || ($clazzType == Byte)) || ($clazzType == Short)))
		{
			$this->Add_String_Integer($_name, $obj);
			return ;
		}
		if (($clazzType == Long))
		{
			$this->Add_String_Long($_name, $obj);
			return ;
		}
		if (($clazzType == Float))
		{
			$this->Add_String_Float($_name, $obj);
			return ;
		}
		if (($clazzType == java.math.BigDecimal))
		{
			$this->Add_String_BigDecimalmathjava($_name, $obj);
			return ;
		}
		if (($clazzType == Double))
		{
			$this->Add_String_Double($_name, $obj);
			return ;
		}
		if (($clazzType == Date))
		{
			$this->Add($_name, $obj);
			return ;
		}
	}
	protected function Add_String_String ($_name, $_val) // [String _name, String _val]
	{
		$en = Para::constructor__();
		$en->DAType = String;
		$en->val = $_val;
		$en->ParaName = $_name;
		$en->Size = $_val->length();
		$this->Add_Para($en);
	}
	protected function Add_String_Integer ($_name, $_val) // [String _name, Integer _val]
	{
		$en = Para::constructor__();
		$en->DAType = Integer;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	protected function Add_String_Long ($_name, $_val) // [String _name, Long _val]
	{
		$en = Para::constructor__();
		$en->DAType = Long;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	protected function Add_String_Float ($_name, $_val) // [String _name, Float _val]
	{
		$en = Para::constructor__();
		$en->DAType = Float;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	protected function Add_String_BigDecimalmathjava ($_name, $_val) // [String _name, java.math.BigDecimal _val]
	{
		$en = Para::constructor__();
		$en->DAType = BigDecimal;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	protected function Add_String_Double ($_name, $_val) // [String _name, Double _val]
	{
		$en = Para::constructor__();
		$en->DAType = Double;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	protected function Add_String_Date ($_name, $_val) // [String _name, Date _val]
	{
		$en = Para::constructor__();
		$en->DAType = Date;
		$en->val = $_val;
		$en->ParaName = $_name;
		$this->Add_Para($en);
	}
	public function remove ($paraName) // [String paraName]
	{
		$i = 0;
		foreach ($this as $p) 		{
			if ($p->ParaName->equals($paraName))
			{
				break;
			}
			++$i;
		}
		$this->remove($i);
	}
	public function AddFK_Emp_String ($userNo) // [String userNo]
	{
		$this->Add_String_String("FK_Emp", $userNo);
	}
	public function AddFK_Emp () 
	{
		$this->Add_String_Double("FK_Emp", $BP->Web->WebUser->getNo());
	}
	public function AddFK_NY_String ($fk_ny) // [String fk_ny]
	{
		$this->Add_String_String("FK_NY", $fk_ny);
	}
	public function AddFK_NY () 
	{
		$this->Add_String_Double("FK_NY", DataType::getCurrentYearMonth());
	}
	public function AddFK_Dept ($val) // [String val]
	{
		$this->Add_String_String("FK_Dept", $val);
	}
	public function ToDesc () 
	{
		$msg = "";
		foreach ($this as $p) 		{
			$msg += ((("@" . $p->ParaName) . " = ") . $p->val);
		}
		return $msg;
	}
	public function getSQLNoPara () 
	{
		$tempVar = $this->SQL;
		$mysql = (( (($tempVar instanceof String)) ? $tempVar : NULL ));
		if (($mysql . NULL))
		{
			return NULL;
		}
		foreach ($this as $p) 		{
			if (($p->DAType . String))
			{
				if ($mysql->contains((($SystemConfig->getAppCenterDBVarStr() + $p->ParaName) . ",")))
				{
					$mysql = $mysql->replace((($SystemConfig->getAppCenterDBVarStr() + $p->ParaName) . ","), (("'" . $p->val) . "',"));
				}
				else
				{
					$mysql = $mysql->replace(($SystemConfig->getAppCenterDBVarStr() + $p->ParaName), (("'" . $p->val) . "',"));
				}
			}
			else
			{
				if ($mysql->contains((($SystemConfig->getAppCenterDBVarStr() + $p->ParaName) . ",")))
				{
					$mysql = $mysql->replace((($SystemConfig->getAppCenterDBVarStr() + $p->ParaName) . ","), ($p->val . ","));
				}
				else
				{
					$mysql = $mysql->replace(($SystemConfig->getAppCenterDBVarStr() + $p->ParaName), $p->val);
				}
			}
		}
		return $mysql;
	}
	public function getDebugInfo () 
	{
		if (($this->debugInfo . NULL))
		{
// 			$sb = ""; // 
			$sb = "";
			$sb.=(("Num=" . $this->size()));
			foreach ($this as $pa) 			{
				$sb.=(((((", " . $pa->ParaName) . "=") . $pa->val) . "("));
				if (($pa->val != NULL))
				{
					$sb.=($pa->val->getClass()->getSimpleName());
				}
				else
				{
					$sb.=("null");
				}
				$sb.=(")");
			}
			$this->debugInfo = $sb;
		}
		return $this->debugInfo;
	}
}
Paras::__staticinit(); // initialize static vars for this class on load
?>
